<include file="../header" />
<body>
<div class="wraper">
	<div class="load">
		<img class="load-bee" src="/assets/base/repair/images/load-bee.png"/>
	</div>
    <div class="top">
        <p>
            <a href="javascript:history.go(-1)" class="iconfont icon-zuo fl-left"></a>
            <span class="text-center pull-left">地址管理</span>
            <a href="#" class="pull-left text-right"> </a>
        </p>
    </div>
    <div class="list-box">
        <if condition="$addressList">
            <volist name="addressList" id="vo">
                <div class="list clearfix <if condition='$vo.default eq 1'>check</if>">
                    <div class="left fl-left"  data-id="{BEESCRM:$vo['address_id']}" data-type="{BEESCRM:$picked}">
                        <p>{BEESCRM:$vo['real_name']} {BEESCRM:$vo['mobile']}</p>
                        <if condition="$vo['user_type'] eq 0">
                            <p class="sub">{BEESCRM:$vo['community_name']} {BEESCRM:$vo['building_name']} {BEESCRM:$vo['room_name']} {BEESCRM:$vo['address_detail']}</p>
                            <else/>
                            <p class="sub">{BEESCRM:$vo['address_detail']} </p>
                        </if>

                    </div>
                    <div class="right fl-left">
                        <a href="javascript:void(0)"class="iconfont icon-del-round shanchu fl-right" data-id="{BEESCRM:$vo['address_id']}" ></a>
                        <a href="/repairhsd/repairhsdAddress/addAddress/address_id/{BEESCRM:$vo.address_id}/repairId/{BEESCRM:$repairId}" class="iconfont icon-jzd_xiugaishuxing bianji fl-right"></a>
                    </div>
                </div>
            </volist>
        <else/>
            <div style="width: 100%;height: 100%"><p style="width:60px;height:30px;position: absolute;left:50%;top:50%;margin-top: -15px;margin-left: -30px;color: #ccc;line-height: 30px;text-align: center;">暂无信息</p></div>
        </if>

    </div>
    <div class="marginb-50"></div>
    <div class="btn-box">
        <a href="{BEESCRM::U('repairhsd/repairhsdAddress/addAddress',array('repairId'=>$repairId))}" class="btn big">新增地址</a>
    </div>
</div>

<include file="../commonJS" />
<script>
$(document).ready(function(){
	$('.list-box').on('click','.list',function(){
		$(this).addClass('check').siblings().removeClass('check');
	});

	$('.left').on('click',function(){
		var address_id = $(this).data('id');
		var type = $(this).data('type');
		if(address_id){
			$.ajax({
				type:'post',
				dataType:'json',
				data:{'address_id':address_id,'type':type},
				url:"{BEESCRM::U('Repairhsd/RepairhsdAddress/addressDefault',array('repairId' => $repairId))}",
				success:function(data){
					if(data.status == 'S'){
						location.href = '/Repairhsd/RepairhsdUserOrder/createOrder/repairId/{BEESCRM:$repairId}/address_id/' + address_id;
					}else{
						$.alert('error',data.message);
					}
				},
				error:function(){
					$.alert('error','网络错误，请重试');
				}
			});
		}
	});


	//删除显示confirm框
	$(document).on('click','.icon-del-round',function(){
		var address_id=$(this).data('id');
		var msg = '确认删除该条地址';
		$.confirm(msg, drop);
		function drop() {
			delLight(address_id)
		}
	});

	//确认删除
	function delLight(address_id){
		if(address_id == ''){
			$.alert('error','参数错误');
            return false;
		}else{
			$.ajax({
				type : 'post',
				dataType : 'json',
				data : {'address_id':address_id,'cut_off':1},
				url : "/Repairhsd/RepairhsdAddress/delAddress/repairId/{BEESCRM:$repairId}",
				success : function(data) {
					if (data.status == 'S') {
						$.alert('success',data.message);
						setTimeout( "window.location.reload()", 2000);
					} else {
						$.alert('error',data.message);
					}
				},
				error : function() {
					$.alert('error','网络错误，请重试');
				}
			});
		}
	}
});
</script>
</body>

</html>
